<template>
  <div class="task">
    <my-header>任务详情<a slot="right" :link="task.href" v-if="task.href">链接</a></my-header>
    <group>
      <cell title="任务名称" :value="task.taskName"></cell>
      <cell title="任务描述" :value="task.desc" v-if="task.desc"></cell>
      <cell title="创建时间" :value="task.createTime"></cell>
    </group>

    <group title="任务分布">
      <cell v-for="(review,idx) in reviewList" 
          :title=" review.dot + '天后，第' + (idx + 1) + '次复习:' + review.reviewTime + (review.hasReviewed ? '  已复习':'') " :key="idx"></cell>
    </group>
  </div>
</template>

<script>
import MyHeader from '@/components/MyHeader'
import { mapState,mapGetters } from 'vuex'
import { format, addDate } from '@/util'
export default {
  name: 'task',
  components:{ MyHeader },
  data () {
    return {
      taskId:'',
      reviewList:[],
      task: {
        id:'',
        name:'',
        href: '',
        curveTypeId:'',
        createTime:''
      }
    }
  },
  computed: {
    ...mapState(['taskList'])
  },
  created(){
    this.taskId = this.$route.query.id
    this.taskList.forEach((item,idx)=>{
      if(item.taskId === this.taskId){
        this.task = item
      }
    })
    this.taskList.forEach((item,idx)=>{
      if(item.taskId === this.taskId){
        this.reviewList = item.reviewList
      }
    })
  },
  methods:{}
}
</script>
<style lang="scss">
.task{
  .content{
    padding: 0 15px;
  }
}
</style>
